package com.example.newproject_overseas.Screen

import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Button
import androidx.compose.material.ButtonDefaults
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.scale
import androidx.compose.ui.focus.focusModifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.navigation.NavHostController
import androidx.navigation.compose.rememberNavController
import com.example.newproject_overseas.R
import com.example.newproject_overseas.components.TopApp

@Composable
fun LivenessDetection(navController: NavHostController) {

    val screenHeightDp = LocalConfiguration.current.screenHeightDp


     Box(  modifier = Modifier
        .fillMaxSize()
        .background(
            color = Color(0XFFEFF0F3)
        )
    ){

        Column(
            modifier = Modifier
                .fillMaxSize()
                .background(color = Color(0XFFEFF0F3)),

            ) {

            TopApp(title = "Liveness detection", navController = navController)

            Column(
                modifier = Modifier
                    .fillMaxSize()
                    .padding(top = 10.dp)
                    .background(Color.White),
                horizontalAlignment = Alignment.CenterHorizontally
            ) {

                Text(
                    text = "Please face the camera",
                    color = Color(0xFFFFCC00),
                    fontSize = 30.sp,
                    modifier = Modifier.padding(top = 20.dp)
                )

            }
        }

        Column(modifier = Modifier.align(Alignment.BottomCenter)) {
            Image(
                painter = painterResource(id = R.drawable.person_photo),
                contentDescription = null,
                modifier = Modifier
                    .height((screenHeightDp * 0.6).dp)
                    .fillMaxWidth(),
                contentScale = ContentScale.FillBounds
            )
            Spacer(modifier = Modifier.height(100.dp))
        }


        //底部按钮
        Button(onClick = { /*TODO*/ }, modifier = Modifier
            .fillMaxWidth(1f)
            .height(65.dp)
            .align(Alignment.BottomCenter),
            colors = ButtonDefaults.buttonColors(Color(0xFFFFCC00)),
            shape = RoundedCornerShape(4.5.dp)
        ) {
            Image(
                painter = painterResource(id = R.drawable.cammer),
                contentDescription = null,
                modifier = Modifier
                    .width(50.dp)
                    .height(50.dp)
                    .fillMaxWidth(),
                contentScale = ContentScale.FillBounds
            )
        }
    }
}

@Preview
@Composable
fun LivenessDetectionPreview() {
    val navController = rememberNavController() // 假设这里使用了导航控制器
    LivenessDetection(navController)
}

